<?php  
defined('APPLICATION_URL')||define('APPLICATION_URL', '/ITjap(tung)/ITjap_finalversion');
session_start();
$userId=$_SESSION['userId'];
if(!isset($userId)) header('Location:'.APPLICATION_URL.'/index.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- head - Finished -->
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<link rel="stylesheet" href="../../css/layout.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="../../css/home.css" type="text/css" media="screen" />
	<link href="../../css/calendar.css"rel="stylesheet" type="text/css">
	<script src="../../js/calendar.js"language="javascript"></script>		
	<title>会議室予約システム</title>
</head>
<!-- /head - Finished -->

<script type="text/javascript">
	function checkForm()
	{
		var x=document.forms["form1"]["UserID"].value;
		var y=document.forms["form1"]["Date"].value;
		var z=document.forms["form1"]["Unauthorized_Time"].value;
		if (x==null || x=="" ||y==null || y=="" || z==null || z=="")
		  {
			  alert("Blank must be filled out");
			  return false;
		  }
		else  if(IsNumeric(z)==false)
		{
			alert("Invalid input time");
			return false;
		}
		else return true;
	}
	
//validatetime
	function  validatetime(strval)
	{
	  var strval1;
	    
	  //minimum lenght is 6. example 1:2 AM
	  if(strval.length < 6)
	  {
	   alert("Invalid time. Time format should be HH:MM AM/PM.");
	   return false;
	  }
	  
	  //Maximum length is 8. example 10:45 AM
	  if(strval.lenght > 8)
	  {
	   alert("invalid time. Time format should be HH:MM AM/PM.");
	   return false;
	  }
	  
	  //Removing all space
	  strval = trimAllSpace(strval); 
	  
	  //Checking AM/PM
	  if(strval.charAt(strval.length - 1) != "M" && strval.charAt(
	      strval.length - 1) != "m")
	  {
	   alert("Invalid time. Time shoule be end with AM or PM.");
	   return false;
	   
	  }
	  else if(strval.charAt(strval.length - 2) != 'A' && strval.charAt(
	      strval.length - 2) != 'a' && strval.charAt(
	      strval.length - 2) != 'p' && strval.charAt(strval.length - 2) != 'P')
	  {
	   alert("Invalid time. Time shoule be end with AM or PM.");
	   return false;
	   
	  }
	  
	  //Give one space before AM/PM
	  
	  strval1 =  strval.substring(0,strval.length - 2);
	  strval1 = strval1 + ' ' + strval.substring(strval.length - 2,strval.length)
	  
	  strval = strval1;
	      
	  var pos1 = strval.indexOf(':');
	  document.Form1.TextBox1.value = strval;
	  
	  if(pos1 < 0 )
	  {
	   alert("invlalid time. A color(:) is missing between hour and minute.");
	   return false;
	  }
	  else if(pos1 > 2 || pos1 < 1)
	  {
	   alert("invalid time. Time format should be HH:MM AM/PM.");
	   return false;
	  }
	  
	  //Checking hours
	  var horval =  trimString(strval.substring(0,pos1));
	   
	  if(horval == -100)
	  {
	   alert("Invalid time. Hour should contain only integer value (0-11).");
	   return false;
	  }
	      
	  if(horval > 12)
	  {
	   alert("invalid time. Hour can not be greater that 12.");
	   return false;
	  }
	  else if(horval < 0)
	  {
	   alert("Invalid time. Hour can not be hours less than 0.");
	   return false;
	  }
	  //Completes checking hours.
	  
	  //Checking minutes.
	  var minval =  trimString(strval.substring(pos1+1,pos1 + 3));
	  
	  if(minval == -100)
	  {
	   alert("Invalid time. Minute should have only integer value (0-59).");
	   return false;
	  }
	    
	  if(minval > 59)
	  {
	     alert("Invalid time. Minute can not be more than 59.");
	     return false;
	  }   
	  else if(minval < 0)
	  {
	   alert("Invalid time. Minute can not be less than 0.");
	   return false;
	  }
	   
	  //Checking minutes completed.
	  
	  //Checking one space after the mintues 
	  minpos = pos1 + minval.length + 1;
	  if(strval.charAt(minpos) != ' ')
	  {
	   alert("Invalid time. Space missing after minute.Time should have HH:MM AM/PM format.");
	   return false;
	  }
	 
	  return true;
	}	
//	trimAllSpace
	function trimAllSpace(str) 
	{ 
	    var str1 = ''; 
	    var i = 0; 
	    while(i != str.length) 
	    { 
	        if(str.charAt(i) != ' ') 
	            str1 = str1 + str.charAt(i); i ++; 
	    } 
	    return str1; 
	}	
//trimString
	function trimString(str) 
	{ 
	     var str1 = ''; 
	     var i = 0; 
	     while ( i != str.length) 
	     { 
	         if(str.charAt(i) != ' ') str1 = str1 + str.charAt(i); i++; 
	     }
	     var retval = IsNumeric(str1); 
	     if(retval == false) 
	         return -100; 
	     else 
	         return str1; 
	}	
//IsNumeric
	function IsNumeric(strString) 
	{ 
	    var strValidChars = "0123456789"; 
	    var strChar; 
	    var blnResult = true; 
	    //var strSequence = document.frmQuestionDetail.txtSequence.value; 
	    //test strString consists of valid characters listed above 
	    if (strString.length == 0) 
	        return false; 
	    for (i = 0; i < strString.length && blnResult == true; i++) 
	    { 
	        strChar = strString.charAt(i); 
	        if (strValidChars.indexOf(strChar) == -1) 
	        { 
	            blnResult = false; 
	        } 
	     }
	     return blnResult; 
	}
	
</script>

<body>
<!-- header area -->
	<div id="header_area">
	  <div id="header">
	    <div id="header_link_area">
	      <a name="pagetop"></a>
	      <div id="header_appeal">会議室予約システム</div>
	      <div id="header_link">
	        <ul>
	          <li class="header_b_1"><a href="admin.php" class="header_b_1"><img src="../../images/header/header_b_1.gif" alt="ホーム" width="56" height="21" /></a></li>
	          <li class="logout"><a href="../../controller/logout.php" class="header_b_2"><img src="../../images/header/header_b_5.gif" alt="logout" width="71" height="21" /></a></li>
	          <li class="setting"><a href="../../change_pass.php" class="header_b_3"><img src="../../images/header/header_b_3.gif" alt="setting"" width="155" height="21" /></a></li>
	          <li class="header_b_4"><a href="../../index.php" class="header_b_4"><img src="../../images/header/header_b_4.gif" alt="お問い合せ" width="82" height="21" /></a></li>
	        </ul>
	      </div>
	    </div>
	    <div id="header_title">
	       <img id="SiteHeader1_imgTitle" src="../../images/header/header_title_1.gif" alt="貸会議室予約" style="height:90px;width:960px;border-width:0px;" /> 
	    </div>
	  </div>
	</div>
<!-- header area-->
	
<!-- pan_area -->
	      <div id="pan_area">
	        <div id="pan">
	          
	        </div>
	      </div>
<!-- pan_area -->
	  
<!-- main_area -->
	<div id="main_top_area">&nbsp;</div>
	    
	<!-- main_middle_area -->   
	<div id="main_middle_area">
	
	    <!-- main area-->
		<div id="main_area">
		
			<!-- main -->
			<div id="main">
				    <!-- navi -->
				      <div id="navi">
				        <ul>
				          <li class="kanrisha_shitsu"><a href="room_manager.php" class="navi_b_1"><img src="../../images/navi/kanrisha_shitsu.gif" alt="kanrisha_shitsu" width="145" height="39" /></a></li>
				          <li class="kanrisha_user"><a href="<?php echo APPLICATION_URL?>/controller/userManagerController.php" class="navi_b_2"><img src="../../images/navi/kanrisha_user.gif" alt="kanrisha_user" width="145" height="39" /></a></li>
				          <li class="kanrisha_penalty"><a href="unauthorized_detect.php" class="navi_b_3"><img src="../../images/navi/kanrisha_penalty.gif" alt="kanrisha_penalty" width="145" height="39" /></a></li>
				        </ul>
				      </div>
				   <!-- /navi -->
				   
				   <!-- contents -->
				       <div id="content">
				       		  <h1><img src="../../images/h1_faq.gif" alt="よくあるご質問" /></h1>
				       		  <h1 style="color: Blue">不定な使用を検出</h1>
				              <p>&nbsp;</p>
		<!-- FORM PHẠT TIỀN -->        
                              <form name="form1" action="../../controller/unauthorizedDetect.php" onsubmit="return checkForm();" method="post">
									  <div id="Unauthorized">			          		
								            <div id="UserID">
									              <label style="font-size: 2em">テナント</label>
									              <input style="margin-left: 87px" name="UserID" type="text" id="UserID" class="width_20" />
								            </div>							          
								            <div id="Date" style="margin-top: 20px">
									              <label style="font-size: 2em">日</label>
									              <input style="margin-left: 117px" name="Date" type="text" id="Date" class="width_20" onclick="showCalendarControl(this);"/>
								            </div>
								            <div id="Unauthorized_Time" style="margin-top: 20px">
									              <label style="font-size: 2em">不定時間</label>
									              <input style="margin-left: 87px" name="Unauthorized_Time" type="text" id="price" class="width_20" />
								            </div>  
								            <!-- button -->		
								              	<input style="margin-top: 20px" type="submit" name="OK" value="OK" id="submit" />
								              	<input style="margin-top: 20px" type="reset" name="OK" value="Reset" id="reset" />								            		            	
							          </div>
						      </form>       
                              <p>&nbsp;</p>        
                              <p>&nbsp;</p>        
                              <p>&nbsp;</p>      
                              <p>&nbsp;</p>        
                              <p>&nbsp;</p>        
                              <p>&nbsp;</p>        
                              <p>&nbsp;</p>        
                              <p>&nbsp;</p>        
                              <p>&nbsp;</p>        
                              <p>&nbsp;</p>
				        </div>
				    <!-- /contents -->
				    
			</div>
	  		<!-- /main -->
	  		
		      <div id="pr"><p>&nbsp;</p></div>
			</div>
	    </div>
	     <!-- /main_middle_area -->
	<div id="main_bottom_area">&nbsp;</div>
<!-- main_area -->
      
<!-- FOOTER -->
	<div id="footer_area">
	  <div id="footer">
	    <ul>
	      <li class="left"><a href="../../index.php">ホーム</a></li>
	      <li><a href="../../view/user/login.php">ログアウト</a></li>
	      <li><a href="../../view/user/register.php">個人情報変更</a></li>
	      <li><a href="../../index.php">Q&A</a></li>
	    </ul>
	    <p>Copyright&nbsp;&copy;&nbsp;Team 08</p>
	  </div>
	</div>
<!-- FOOTER -->
</body>
</html>